<?php
/**
 * Created by PhpStorm.
 * User: asdf
 * Date: 2021/9/18
 * Time: 16:46
 */
namespace core;


function p($var){
        echo "<div style='color: midnightblue;
                background-color: aliceblue;
                border: 2px darkblue solid;
                word-wrap: break-word;
                word-break: normal;
                margin-top: 1em;
                '>"
            .(htmlentities(print_r($var,true))).
            "</div>";
}

function pplain($var){
    echo (htmlentities(print_r($var,true)));
}

function alert($var){
    $dis = htmlentities(print_r($var,true));
    echo "<script>alert('$dis')</script>";
}

function backto($var){
    $var = htmlentities($var);
    echo "<script>window.location.href = '$var' </script>";
}

function backto2($var){
    header("location:$var");
}

function a($href,$name){
    $href = htmlentities($href);
    $name = htmlentities($name);
    echo "<a href='$href'>$name</a>";
}

function tp($var){
    $regex = "/(\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\|\||\"){1,}/";
    $other = preg_replace($regex,"",$var);
    $regex = "/(，|。|！|；|：|、|’|‘|【|】|《|》|？|@|#|￥|%|&|\*|（|）|\-|\+|\=|@|…){2,}/";
    $other = preg_replace($regex,"",$other);
    echo $other;
}

function rtp($rtp){
    $regex = "/(\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\|\||\"){1,}/";
    $other = preg_replace($regex,"",$rtp);
    $regex = "/(，|。|！|；|：|、|’|‘|【|】|《|》|？|@|#|￥|%|&|\*|（|）|\-|\+|\=|@|…){2,}/";
    $other = preg_replace($regex,"",$other);
    return $other;
}